
#include "config.h"

#define IOx_S_KR00  GPIOA ,4u
#define IOx_S_KR01  GPIOA ,5u
#define IOx_S_KR02  GPIOA ,6u
#define IOx_S_KR03  GPIOA ,7u
#define IOx_S_KR04  GPIOB ,0u
#define IOx_S_KR05  GPIOB ,1u
#define IOx_S_KR06  GPIOB ,2u
#define IOx_S_KR07  GPIOB ,10u
#define IOx_S_KR08  GPIOB ,11u
#define IOx_S_KR09  GPIOB ,12u
#define IOx_S_KR10  GPIOB ,13u
#define IOx_S_KR11  GPIOB ,14u
#define IOx_S_KR12  GPIOA ,15u
#define IOx_S_KR13  GPIOD ,0u
#define IOx_S_KR14  GPIOD ,1u
#define IOx_S_KR15  GPIOD ,2u
#define IOx_S_KR16  GPIOD ,3u
#define IOx_S_KR17  GPIOB ,3u
#define IOx_S_KR18  GPIOB ,4u
#define IOx_S_KR19  GPIOB ,5u

#define KR00_state_S IF_I_H_(IOx_S_KR00)  
#define KR01_state_S IF_I_H_(IOx_S_KR01)  
#define KR02_state_S IF_I_H_(IOx_S_KR02)  
#define KR03_state_S IF_I_H_(IOx_S_KR03)  
#define KR04_state_S IF_I_H_(IOx_S_KR04)  
#define KR05_state_S IF_I_H_(IOx_S_KR05)  
#define KR06_state_S IF_I_H_(IOx_S_KR06)  
#define KR07_state_S IF_I_H_(IOx_S_KR07)  
#define KR08_state_S IF_I_H_(IOx_S_KR08)  
#define KR09_state_S IF_I_H_(IOx_S_KR09)  
#define KR10_state_S IF_I_H_(IOx_S_KR10)  
#define KR11_state_S IF_I_H_(IOx_S_KR11)  
#define KR12_state_S IF_I_H_(IOx_S_KR12)  
#define KR13_state_S IF_I_H_(IOx_S_KR13)  
#define KR14_state_S IF_I_H_(IOx_S_KR14)  
#define KR15_state_S IF_I_H_(IOx_S_KR15)  
#define KR16_state_S IF_I_H_(IOx_S_KR16)  
#define KR17_state_S IF_I_H_(IOx_S_KR17)  
#define KR18_state_S IF_I_H_(IOx_S_KR18)  
#define KR19_state_S IF_I_H_(IOx_S_KR19)  


static inline void IO_INIT_S1(void)
{
	LED_IO_INIT();
	One_PIN_init_(IOx_S_KR00, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR01, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR02, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR03, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR04, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR05, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR06, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR07, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR08, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR09, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR10, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR11, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR12, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR13, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR14, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR15, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR16, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR17, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR18, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
	One_PIN_init_(IOx_S_KR19, LL_GPIO_MODE_INPUT, LL_GPIO_SPEED_MEDIUM, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_NO);
}

/**
*@author     2025.10.29 WangXQ
*@brief      
*@param      void
*@return     void
**/
void Deal_S(void)
{
	IO_INIT_S1();
	SysTick_init(1000);
	COM1_Init(115200, WordL_8, StopBits_1, Parity_no, 0);
	COM2_Init(115200, WordL_8, StopBits_1, Parity_no, 0);
	printf_my("\r\n%s_S, HARD_FLAG:%02X", Version, HARD_FLAG);
	while (1)
	{
//		printf_my("\r\n^M^");
// 		u32 BitF = 0x01;
// 		for (u8 i = 0; i < 20; i++)
// 		{
// 			if (BitF & Data_Buf[0]) printf_my(" 1 ");
// 			else  				    printf_my(" 0 ");
// 			BitF <<= 1;
// 		}
		OSTimeDly(ms2000);
	}
}
/**
*@author     2025.10.29 WangXQ
*@brief       
*@param      void
*@return     void
**/
void SysTick_Handler_S_1mA(void)
{
	static u8 T_10ms = 0;

	switch (T_10ms++)
	{
	case 0:	T_10ms = 1; KR_LB_DEAL_00_15(0, KR00_state_S);  KR_LB_DEAL_00_15(10, KR10_state_S); break;
	case 1:	T_10ms = 2; KR_LB_DEAL_00_15(1, KR01_state_S);  KR_LB_DEAL_00_15(11, KR11_state_S); break;
	case 2: T_10ms = 3; KR_LB_DEAL_00_15(2, KR02_state_S);  KR_LB_DEAL_00_15(12, KR12_state_S); break;
	case 3:	T_10ms = 4; KR_LB_DEAL_00_15(3, KR03_state_S);  KR_LB_DEAL_00_15(13, KR13_state_S); break;
	case 4: T_10ms = 5; KR_LB_DEAL_00_15(4, KR04_state_S);  KR_LB_DEAL_00_15(14, KR14_state_S); break;
	case 5:	T_10ms = 6; KR_LB_DEAL_00_15(5, KR05_state_S);  KR_LB_DEAL_00_15(15, KR15_state_S); break;
	case 6:	T_10ms = 7; KR_LB_DEAL_00_15(6, KR06_state_S);  KR_LB_DEAL_16_31(16, KR16_state_S); break;
	case 7:	T_10ms = 8; KR_LB_DEAL_00_15(7, KR07_state_S);  KR_LB_DEAL_16_31(17, KR17_state_S); break;
	case 8:	T_10ms = 9; KR_LB_DEAL_00_15(8, KR08_state_S);  KR_LB_DEAL_16_31(18, KR18_state_S); break;
	default:T_10ms = 0; KR_LB_DEAL_00_15(9, KR09_state_S);  KR_LB_DEAL_16_31(19, KR19_state_S);
	{
		static u16 T_LED_2S = 0;
		if (++T_LED_2S == 10+150) { T_LED_2S = 0; }

		if (    T_LED_2S < 10 
// 			|| ((35  < T_LED_2S) && (T_LED_2S < 45)) 
// 			|| ((70  < T_LED_2S) && (T_LED_2S < 85))
// 			|| ((105 < T_LED_2S) && (T_LED_2S < 115))
			)
		{
			LED0_ON;
		}
		else
		{
			LED0_OF;
		}
	}
		
		break;
	}

	


}

